package com.xiaochao.lcrapiddevelop.UI;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.xiaochao.lcrapiddevelop.Constant.Constant;
import com.xiaochao.lcrapiddevelop.MVP.View.BaseLoadView;
import com.xiaochao.lcrapiddevelop.R;
import com.xiaochao.lcrapiddeveloplibrary.viewtype.LoadLayout;

/**
 * Copyright (C), 2016-2030, ShenZhenSmartTimeTech. Co., Ltd.
 * FileName:BaseLoadActivity.java
 *
 * @author zhwang
 * @version 0.9.1
 * @Date 2017/7/4
 */


public abstract class BaseLoadActivity extends AppCompatActivity implements BaseLoadView {
	LoadLayout loadLayout;

	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setLayout(R.layout.activity_base_load);
		loadLayout = (LoadLayout) findViewById(R.id.load_layout);
	}

	protected void setLayout(int layoutRes) {
		setContentView(layoutRes);
	}

	@Override
	public void showProgress() {
		loadLayout.showLoading( );

	}

	@Override
	public void hideProgress() {
		loadLayout.showContent( );
	}

	@Override
	public void showLoadFailMsg() {
		loadLayout.showError(getResources( ).getDrawable(R.mipmap.monkey_cry), Constant.ERROR_TITLE,
				Constant.ERROR_CONTEXT, Constant.ERROR_BUTTON, new View.OnClickListener( ) {
					@Override
					public void onClick(View v) {
						loadLayout.showLoading( );
						loadData( );
					}
				});
	}


	@Override
	public void showNoData() {
		loadLayout.showEmpty(getResources( ).getDrawable(R.mipmap.monkey_nodata), Constant.EMPTY_TITLE,
				Constant.EMPTY_CONTEXT);
	}

}
